package com.ruoyi.system.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 物料分类枚举（对应materialCategory字段）
 */
@Getter
@AllArgsConstructor
@ApiModel(value = "MaterialCategoryEnum", description = "物料分类枚举（1=主材，2=辅材，3=家具软装，4=厨卫定制，5=全屋家具定制，6=工程项目）")
public enum MaterialCategoryEnum {
    @ApiModelProperty(value = "工程项目")
    ENGINEERING_PROJECT(1, "工程项目"),

    @ApiModelProperty(value = "辅材")
    AUXILIARY_MATERIAL(2, "辅材"),

    @ApiModelProperty(value = "硬装主材")
    MAIN_MATERIAL(3, "硬装主材"),

    @ApiModelProperty(value = "家具软装")
    FURNITURE_SOFT(4, "家具软装"),

    @ApiModelProperty(value = "厨卫定制")
    KITCHEN_BATH_CUSTOM(5, "厨卫定制"),

    @ApiModelProperty(value = "全屋家具定制")
    WHOLE_HOUSE_CUSTOM(6, "全屋家具定制"),

    @ApiModelProperty(value = "照明设计")
    LIGHTING_OUTFIT(7, "照明设计");




    @EnumValue
    private final Integer code;

    @JsonValue
    private final String desc;

    /**
     * 根据code获取枚举
     */
    public static MaterialCategoryEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        return Arrays.stream(values())
                .filter(enumItem -> enumItem.code.equals(code))
                .findFirst()
                .orElse(null);
    }
}